#!/usr/bin/env node

const http = require('http'),
      qs = require('querystring');
//url:http://localhost:8080/add?x=2&y=3

http.createServer((req,res)=>{
  console.log(`${req.method} ${req.url} HTTP/${req.httpVersion}`);
  console.log(req.headers);

  if(req.method!='POST'){
    res.end('ok');
    return;
  }
  let data='';
  req.on('data',(chunk)=>{ data+=chunk; } );
  req.on('end',()=>{
    console.log(qs.parse(data));
    res.end('ok');
  })
}).listen(3000);
